package com.lovo;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

public class Test0 extends JFrame {
    private CardLayout cardLayout = new CardLayout();
    private Menu menu1 = new Menu(this);
    private Login log1 = new Login(this);
    private Lnquire lnquire =new Lnquire(this);
    private Savers savers =new Savers(this);
    private Withdrawal teller =new Withdrawal(this);
    private Revise revise=new Revise(this);
    private Transfer transfer=new Transfer(this);
    private ArrayList<Uesr> list = new ArrayList();
    private Uesr uesr;
    private int number;

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public Uesr getUesr() {
        return uesr;
    }

    public void setUesr(Uesr uesr) {
        this.uesr = uesr;
    }

    public Lnquire getLnquire() {
        return lnquire;
    }

    public void setLnquire(Lnquire lnquire) {
        this.lnquire = lnquire;
    }



    public ArrayList<Uesr> getList() {
        return list;
    }

    public void setList(ArrayList<Uesr> list) {
        this.list = list;
    }

    private Image image1 = Util.getImage("/img/background.jpg");



    public Test0() {
        init();
        //传入背景图
        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(image1, 0, 0, 1024, 768, this);
            }
        });



        //卡片
        this.setLayout(cardLayout);

        this.add("login", log1);
        this.add("menu", menu1);
        this.add("lnquire",lnquire);
        this.add("save",savers);
        this.add("teller",teller);
        this.add("revise",revise);
        this.add("transfer",transfer);


        //窗口体大小
        this.setSize(1024, 768);
        //居中
        this.setLocationRelativeTo(null);
        //关闭内存
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        //窗口可视化
        this.setVisible(true);
    }

    public void init() {
        list.add(new Uesr("zhangsan", "123", 1000));
        list.add(new Uesr("wangwu", "456", 1500));
        list.add(new Uesr("lisi", "789", 800));
        list.add(new Uesr("xiaohong", "111", 1200));
        list.add(new Uesr("xiaozhang", "222", 2000));
    }



        public void switchPanel (String name){
            cardLayout.show(this.getContentPane(), name);
        }

        public static void main (String[]args){

            new Test0();
        }


    }